<?php
/**
 * ZYSHOP 控制台首页
 * ============================================================================
 * 网络科技有限公司，并保留所有权利。
*/

define('IN_ZYS', true);
require(dirname(__FILE__) . '/includes/init.php');

if($_REQUEST['act']=='goods_sx') {
    $ranks = array();
    $ranks = $db->getAll("SELECT * FROM " .$zys->table('goods_sx') . "where del_status=0");
    $smarty->assign('region_list',   $ranks);
    $smarty->assign('ur_here',      $_LANG['goods_sx']);
    $smarty->display('goods_sx.html');
}elseif($_REQUEST['act']=='goods_add') {
    $id = $_POST['id'];
    $name = $_POST['name'];
    $content = $_POST['content'];
    if (empty($id)) {
        $sql = "INSERT INTO " . $zys->table('goods_sx') . "( " .
            "name,content" .
            ") VALUES (" .
            "'$name', '$content')";
        $res = $db->query($sql);
        if ($res = 1) {
            header ("Location:goods_sx.php?act=goods_sx");
        } else {
            header("Location:goods_sx.php?act=goods_sx");
        }
    }
}elseif($_REQUEST['act']=='edit'){
	$id = $_POST['id'];
    $name = $_POST['name'];
    $val = $_POST['val'];
    $sql = "UPDATE " . $zys->table('goods_sx') . " SET $name = '{$val}' where id = '{$id}'";
    $res = $db->query($sql);
    if($res){
        echo 1;
    }
}elseif($_REQUEST['act']=='del'){
	$id=$_GET['id'];
	$sql = "UPDATE " . $zys->table('goods_sx') . " SET del_status=1 where id = '$id'";
	$res = $db->query($sql);
	if($res==1){
		header("Location:goods_sx.php?act=goods_sx");
	}else{
		header("Location:goods_sx.php?act=goods_sx");
	}
}



